package org.infinitest.swingui;

import static org.infinitest.EventFakeSupport.*;
import static org.infinitest.TestEvent.*;
import static org.junit.Assert.*;

import javax.swing.JFrame;

import org.junit.Test;

public class WhenInfoFrameIsShowing
{
  @Test
  public void shouldCloseWithEscapeKey() throws Exception
  {
    EventInfoFrame frame = new EventInfoFrame(withAnyTest());
    assertEquals(frame.getRootPane().getActionMap().keys()[0], "ESCAPE");
  }

  public static void main(String[] args)
  {
    AssertionError assertionError = new AssertionError("This is a very long error message. Who would type such a message? It's crazy. This is much too long. This must be stopped. It cannot be allowed to continue.");
    EventInfoFrame frame = new EventInfoFrame(testMethodError("message", assertionError));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}
